
import $api from "@/api/index.js"
import $i18n from "@/utils/i18n.js" // 多语言
export default {
	state: {
		orderTabs:[{
			name: $i18n.tc('my_receive.navs-all'),
			state:'0'
		},{
			name: $i18n.tc('my_receive.navs-wait'),
			state:'1'
		},{
			name: $i18n.tc('my_receive.navs-audit'),
			state:'2'
		},{
			name: $i18n.tc('my_receive.navs-fail'),
			state:'3'
		},{
			name: $i18n.tc('my_receive.navs-success'),
			state:'4'
		}],
		param: {
			page: 1,
			state: '',
		},
		list: {
			data: [],
			last_page: 1,
			current_page: 1
		},
		merchantParam: {
			page: 1,
			state: '',
			task_id:'',
			user_id:''
		},
		merchantList: {
			data: [],
			last_page: 1,
			current_page: 1
		},
	},
	mutations: {
		updateTaskOrderState(state, item) {
			let {
				key,
				val
			} = item
			state[key] = val
		}
		
	},
	actions: {
		
		// 获取我的接单列表
		async getTaskOrderList({
			commit,
			state
		}, param) {
			let res = await $api.task.getTaskOrderList(param)
			// console.log(param)
			let oldList = state.list;
			let newList = res.data;
			let list = {}
			if (param.page == 1) {
				list = newList;
			} else {
				newList.data = oldList.data.concat(newList.data) // 合并数组
				list = newList;
			}
			// console.log(param)
			commit('updateTaskOrderState', {
				key: 'list',
				val: list
			})
		},
		
	}
}